#include "cpu/exec/helper.h"

make_helper(ret){
    current_sreg = R_SS;
    cpu.eip = swaddr_read(reg_l(R_ESP), 4);
    reg_l(R_ESP) += 4;
    print_asm(str(retl));
    cpu.eip -= 1;
    return 1;
}

make_helper(ret_i){
    current_sreg = R_DS;     //本来应该是CS，但是指导书里只写了DS 和 SS
    uint16_t imm16 = swaddr_read(eip + 1, 2);
    current_sreg = R_SS;
    cpu.eip = swaddr_read(reg_l(R_ESP), 4);
    reg_l(R_ESP) += 4;
    reg_l(R_ESP) += imm16;
    snprintf(op_src->str, OP_STR_SIZE, "$0x%x", imm16);
    print_asm(str(ret)" %s", op_src->str);
    cpu.eip -= 3;
    return 3;
}